<template>
  <div o-Container>
    <!-- created: create, -->
    <o-list v-bind:source="list.contract"
      v-bind="{ searched: search, exported: output }">
      <template slot="config" slot-scope="scope">
        <div class="img_box">
            <img @click="modify(scope.data.row,'2')"
              src="../../../../../static/skin/default/MCS/AIGC/Inventory/images/chakan.png" alt="">
            <img @click="modify(scope.data.row,'1')" :class="{disable: isDisabled(scope.data.row)}"
              src="../../../../../static/skin/default/MCS/AIGC/Inventory/images/tongguo.png" alt="">
            <img @click="modify(scope.data.row,'0')" :class="{disable: isDisabled(scope.data.row)}"
              src="../../../../../static/skin/default/MCS/AIGC/Inventory/images/bohui.png" alt="">
          </div>
        </template>
    </o-list>
    |
  </div>
</template>

<script>
export default {
  components: {
    
  },
  data() {
    return {
      octopus: this.$parent.octopus,
      list: {
        contract: {
          data: {
            id: "",
            cellData: [
              
            ],
            paramData: {}
          },
          configWidth:80,
          showNumber:true
        },
      },
      panel: {
        visible: false,
      },
    }
  },
  created() {
    this.init()
  },
  methods: {
    // create: function () {//弹出创建页面
    //   this.item.contract.data.value = null;
    //   this.item.contract.control.load();
    //   this.panel.visible = true;
    // },
    // 修改状态
    init() {
      const data = this.list.contract.data
      let company = this.octopus.passport.authorization.company
      data.paramData.CompanyID = company == 1 ? 'NULL' : company
    },
    amendType(item){
      let this_ = this
      this.octopus.request.api.post(
        "/Octopus/Engine/Item",
        {
          type:'UPDATE',
          id: 748,
          cellData: [
            {name: "Status",defaultValue:item.type},	// 权益状态（保存未提交（草稿箱）、已提交/待审核、审核通过、审核未通过、未启用，启用、已售完、到期）
          ],
          value:this_.compileData.ID
        },
        function (data) {
          if (data.status.code == 200) {
            this_.$refs.auditDrawer.drawerClose()
            this_.list.contract.control.load();
          } else {
            this_.$refs.auditDrawer.drawerClose()
            this_.list.contract.control.load();
            o.octopus.tips.error(data);
          }
        });
    },
    output: function (data) {
      this.octopus.tips.success("下载完成。");
    },
    search: function (cell) {
    },
    modify(row,type) {//修改页面
      if(type == 2 || !this.isDisabled(row)) {
        this.$refs.auditDrawer.drawerOp()
      }
    },
    view: function (row) {
      alert("view key: " + JSON.stringify(row));
    },
    save: function (data) {// 保存
      this.octopus.tips.success(data);
      // 刷新list
      this.list.contract.control.load();
      this.back();
    },
    back: function () {
      this.panel.visible = false;
    },
    refresh() {
      this.list.contract.control.load();
    },

    isDisabled(row) {
      return row.Status == 5 || row.Status == 4
    },
    del: function (row) {
      let o = this
      // alert("del key: " + JSON.stringify(row));
      this.$confirm('此操作将永久删除该项, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.octopus.request.api.post("/Octopus/Engine/Item", {
          id: 1188, // 菜单表的八爪鱼ID
          type: "DELETE",
          value: row.ID,
          cellData: [
            { name: "ID", defaultValue: row.ID },
          ],
        },
        (data) => {
            if (data.status.code === 200) {
              o.list.contract.control.load();
            } else {
              o.octopus.tips.error(data);
            }
          }
        );
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
  },
  props: ["oData"]
}
</script>
<style scoped>
.el-message-box {
  background-color: #fff !important;
}
.btnclass {
  margin-left: 4px;
  border: none;
  padding: 2px 4px;
  border-radius: 2px;
  white-space: nowrap;
}
.info {
  background-color: #F78C51;
  color: #fff;
}

.img_box {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.img_box img {
  width: 25px;
  cursor: pointer;
}
.img_box .disable {
  cursor: not-allowed;
  opacity: 0.5;
}
</style>
